|---------------B A T C H L R N  H E L P  S Y S T E M-----------------|
|command: IF                                                          |
|use: The IF subcommand allows you to direct the decision-making pro- |
| cess in batch processing files (referred to as statement "testing").|
|								      |
|how: Type: IF <condition> <DOS or batch command> [see*&**NEXT]       |
| **<command> == Any legal DOS command or batch file subcommand       |
| *<condition> == One of three tests that yield a true or false re-   |
| sult:								      |
|               1. The ERRORLEVEL of a program (see below)            |
|               2. Two strings that are equivalent or the same.       |
|               3. A file that exists in the CURRENT directory.       |
|                                                                     |
|explanation:The IF command tests for true or false. IF true, it per- |
| forms the command. IF NOT true,it skips the command and goes to the |
| NEXT line in the batch processing file. You can "test" SEVERAL lines|
| one after the other, so that if the first line is not true the batch|
| file moves to the next "testing" line. This will continue until no  |
| more tests are left or a TRUE statement directs a command(like GOTO)|
|		                                                      |
|examples: Refer to BATSEEK.BAT to see the file testing for the pres- |
| ence of.EXE &.COM files, the GOTO command & the failure to meet the |
| presence of the %1 variable (you JUST typed BATSEEK, nothing else). |
|actual pgm:The following batch file can be used to establish a pass- |
| word for running a program. The batch file is named PASSWRD.BAT and |
| calls up a fictitious program name MY.COM:                          |
|    {NOTE:[fghev xcvw] == our notes  & 0) represents EDLIN line #s}  |
| 1) ECHO OFF       [allows messaging in file w/next cmnd.            |
| 2) CLS            to clear the ECHO OFF from the screen]            |
| 3) IF %1 == ABC GOTO FINE [this is the label][IF TRUE,JUMP occurs]  |
| 4) ECHO BAD PASSWORD--ENDING [msg./appears if NO ABC,then NO JUMP]  |
| 5) GOTO END [ALWAYS end EA.cmnd.sequencing with this cmnd/label]    |
| 6) :FINE  [first label to wh/file JUMP occurs when statement TRUE]  |
| 7) ECHO YOU'RE IDENTIFIED--STARTING CMD.SEQUENCE [msg/1st part:GOOD]|
| 8) MY   [the command portion of the :GOOD command sequence]         |
| 9) GOTO END [remember, end each command sequence this way]          |
|10) :END [the second JUMP label--remember labels direct traffic]     |
|11) ECHO I'VE DONE MY JOB!--RETURNING TO CURRENT DRIVE [end msg.]    |
|elucidation:Look at the response of the computer to various cmds.    |
| First a BAD password. At the prompt type: PASSWRD XYZ [xyz==%1]     |
| The computer tests for TRUE [it's NOT since %1 doesn't == ABC] and  |
| [goes to NEXT line] performs NEXT command, which is to display msg: |
|                       BAD PASSWORD--ENDING                          |
| Now, a GOOD password. At the prompt type: PASSWRD ABC [now,abc==%1] |
| The computer tests for TRUE [it IS since %1 == ABC] and performs the|
| GOTO :FINE command and performs JUMP to label :FINE. P.C.then does  |
| what you told it to do after the label :FINE and performs the comm- |
| and prompt "MY" after acknowledging the passwrod with a message. Af-|
| ter MY performs you are returned to :END and sign off. Note the cmd.|
| MY will not appear because echo is off and you didn't call for ECHO.|
| The :END label displays the final message, but there is no require- |
| ment that additional lines appear after end.                        |
|							              |
|NOTES: Unlike programming languages, which allow many logical tests  |
| in an IF statement, the batch IF statement is limited to only the   |
| three named above. TO FURTHER EXPLAIN:                              |
|  >Condition 1:ERRORLEVEL is a number that indicates to DOS whether  |
|  the last program run was succesful. A zero (0) indicates a good    |
|  run, anything above zero indicates an error condition (only DOS    |
|  commands BACKUP and RESTORE have an exit code). You probably WILL  |
|  NOT have use for this feature often. There ARE commercial programs |


|  which make extensive use of ERRORLEVEL.These allow PC-User response|
|  and other features like alternate selection via Yes & No or selec- |
|  tion of numbers and/or letters (1,2,3,4 OR a,b,c,d, etc.).         |
|                                                                     |
|  >Condition 2:String comparison is indicated by a double equal sign:|
|                        String1 == String22                          |
| This compares the two strings. It is often used with parameters and |
| markers to check for a particular entry. For example:               |
| IF %1 == 40  typing:"MODE C40" checks parameter one for 40 and, if  |
| if the condition is TRUE [%1 == 40] it changes the display to 40-   |
| columns wide. [SEE batch files on this disk for examples/study them]|
|                                                                     |
|   >Condition 3:The logical test for checking for the existence of a |
| file has as its format: EXIST C:<filename.ext>                      |
| You can use this test to check and see if a file is in C: drive     |
| (as in the example). EXIST B:<filename.ext> might be used to check  |
| to see if B: drive has a DOS disk in the drive. Explore other uses  |
| after examining files on this disk with "EXIST". Note: you cannot   |
| use pathnames for checking on a file's existence.                   |
|							              |
|----------------- T  I  M  E  M  A  S  T  E  R  ---------------------|
